package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.zzyl.base.ResponseResult.success;

@RestController
@RequestMapping("/nursingLevel")
public class NursingLevelController {

    @Autowired
    NursingLevelService nursingLevelService;

    @GetMapping("/listAll")
    @ApiOperation("查询所有护理等级")
    public ResponseResult<List<NursingLevelVo>> queryNursingLevelAll(){
        List<NursingLevelVo> nursingLevelVoList = nursingLevelService.queryNursingLevelAll();
        return success(nursingLevelVoList);
    }

    @PostMapping("/insert")
    @ApiOperation("新增护理等级")
    public ResponseResult addNursingLevel(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.addNursingLevel(nursingLevelDto);
        return success();
    }

    @GetMapping("listByPage")
    @ApiOperation("条件分页查询护理等级")
    public ResponseResult<PageResponse<List<NursingLevelVo>>> queryNursingLevelByPage(
            @ApiParam(value = "护理等级名称")
            @RequestParam(value = "name",required = false) String name,
            @ApiParam(value = "护理等级状态：0-禁用，1-启用")
            @RequestParam(value = "status",required = false) Integer status,
            @ApiParam(value = "当前页码")
            @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页显示数量")
            @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize
            ){
        PageResponse<NursingLevelVo> pageResponse = nursingLevelService.queryNursingLevelByPage(name,pageNum,pageSize,status);
        return success(pageResponse);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理等级")
    public ResponseResult<NursingLevelVo> getNursingLevelById(@PathVariable Long id){
        NursingLevelVo byPage = nursingLevelService.getNursingLevelById(id);
        return success(byPage);
    }

    @PutMapping("/update")
    @ApiOperation("修改护理计划")
    public ResponseResult updateNursingLevel(@RequestBody NursingLevelVo nursingLevelVo){
        nursingLevelService.updateNursingLevel(nursingLevelVo);
        return success();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除护理等级")
    public ResponseResult deleteNursingLevel(@PathVariable Long id){
        nursingLevelService.deleteNursingLevel(id);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用护理等级")
    public ResponseResult updateNursingLevelStatus(Long id,Integer status){
        nursingLevelService.updateNursingLevelStatus(id,status);
        return success();
    }
}


















